home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: news.sprintlink.net!news1!news
- From: rclark@iquest.net (Robert B. Clark)
- Subject: Re: gets(rec->num); I don't know what I am doing wrong...
- X-Nntp-Posting-Host: ind-004-236-169.iquest.net
- Message-ID: <3129dbf1.656738@news.iquest.net>
- Sender: news@iquest.net (News Admin)
- Organization: IQuest Internet, Inc.
- X-Newsreader: Forte Agent .99d/16.182
- References: <4fempt$mjg@aphex.direct.ca>
- Date: Tue, 20 Feb 1996 15:45:00 GMT
-
- On 9 Feb 1996 05:41:17 GMT, etoivane@direct.ca (Ed Toivanen) wrote:
-
- >int main(void){
- > char studentList[8 + 1];
- > FILE * filePtr;
- >
- > printf("Enter database file to open\n");
- > while(!gets(studentList))
-
- This is okay...
-
- >bool addRecord(FILE* fp, STUDENT_RECORD* rec){
- > printf("Student id\n");
- > gets(rec->id);
-
- ...but this not. gets() is defined as
-
- char * gets(char *s)
-
- gets() expects a pointer to char and returns a pointer to char or EOF or
- NULL.
-
- Here, you've passed an integer (the id field of the rec struct) to
- gets(). Either use a temporary string buffer for the gets() call and
- then convert to an integer or use scanf() to input an integer value
- directly.
- --
- Robert B. Clark <rclark@iquest.net>
- "Be wary of strong spirits. It can make you shoot at tax collectors...
- and miss." --RAH
-